home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Ken Long / PaletteAnim-c / Color Boxes / colorBox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-04  |  1.4 KB  |  77 lines  |  [TEXT/KAHL]

  1. # include <Palettes.h>
  2.  
  3. # define BASE_RES_ID        400
  4. # define NIL_POINTER        0L
  5. # define MOVE_TO_FRONT        -1L
  6. # define CLUT_ID            130
  7. # define PALETTE_ID            1288
  8. # define SRC_USAGE            2
  9. # define SRC_TOLERANCE        0
  10. # define REMOVE_ALL_EVENTS    0
  11. # define BallWidth            10
  12. # define BallHeight            10
  13.  
  14.  
  15. WindowPtr        gHelloWindow;
  16. RGBColor        myRGB;    
  17. Point            *mouseLoc;
  18. int                x,y,c, top, bottom;
  19. PaletteHandle    gThePalette;
  20. CTabHandle        gTheCLUT;
  21. Rect            myRect;
  22.  
  23.  
  24.  
  25. /******************** Main ********************/
  26. main()
  27. {
  28.     ToolBoxInit();
  29.     WindowInit();
  30. }
  31.  
  32.  
  33.  
  34. /******************** ToolBoxInit ********************/
  35. ToolBoxInit()
  36.  
  37. {
  38.     InitGraf ( &qd.thePort );
  39.     InitFonts();
  40.     FlushEvents ( everyEvent,  0 );
  41.     InitWindows();
  42.     InitMenus();
  43.     TEInit();
  44.     InitDialogs( 0L );
  45.     InitCursor();
  46. }
  47.  
  48.  
  49. /******************** WindowInit ********************/
  50. WindowInit ()
  51. {    
  52.  
  53.     gHelloWindow = GetNewCWindow ( BASE_RES_ID, 0L, (WindowPtr)-1L );
  54.     SetPort ( gHelloWindow );
  55.     gTheCLUT = GetCTable ( CLUT_ID );
  56.     gThePalette = GetNewPalette ( PALETTE_ID );
  57.     CTab2Palette ( gTheCLUT, gThePalette, 2, 0);
  58.     SetPalette ( gHelloWindow, gThePalette, TRUE );
  59.     ActivatePalette ( gHelloWindow );
  60.     while ( !Button() )
  61.     {
  62.         for ( x=1; x<18; x++)
  63.         {
  64.             top = x * 18;
  65.             for ( y=1; y<18; y++)
  66.             {
  67.                 bottom = y * 18;
  68.                 SetRect ( &myRect, bottom, top, bottom+15, top+15 );
  69.                 c++;
  70.                 if ( c > 256 )
  71.                     c = 0;
  72.                 PmForeColor ( c );
  73.                 PaintRect ( &myRect );
  74.             }
  75.         }
  76.     }
  77. }